#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <string.h>

pthread_t ntid;

void print_id(const char *s)
{
  pid_t pid;
  pthread_t tid;

  pid = getpid();
  tid = pthread_self();

  printf("%s pid %u tid %lu (%#lx)\n",s,pid,tid,tid);
}


void* thread_fn(void* arg)
{
  print_id("new thread: ");
  return (void*)0;
}

int main()
{
  int err;
  err = pthread_create(&ntid, NULL, thread_fn, NULL);
  if(err != 0)
    puts(strerror(err));

  print_id("main thread: ");
  sleep(1);
  return 0;
}
